package com.nandi.emergencyinspection.ui.adapter

import android.app.Activity
import android.app.ActivityOptions
import android.content.Intent
import android.widget.ImageView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.module.LoadMoreModule
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.nandi.emergencyinspection.R
import com.nandi.emergencyinspection.bean.MacroInfoListBean
import com.nandi.emergencyinspection.weight.imgselect.GlideEngine
import com.nandi.emergencyinspection.ui.activity.ImgActivity

/**
 * @创建者: qingsong
 * @创建时间: 2021/3/25 16:15
 * @描述:
 */
class MacroInfoImgAdapter(data: MutableList<MacroInfoListBean.RecordsBean.VoListBean>) :
    BaseQuickAdapter<MacroInfoListBean.RecordsBean.VoListBean, BaseViewHolder>(
        R.layout.macro_info_img_item,
        data
    ),
    LoadMoreModule {
    override fun convert(
        holder: BaseViewHolder, item: MacroInfoListBean.RecordsBean.VoListBean
    ) {
        val view = holder.getView<ImageView>(R.id.img)
        GlideEngine.createGlideEngine().loadImage(context, item.fileVO?.netUrl.toString(), view)
        holder.setText(R.id.text, item.name)
        view.setOnClickListener {
            context.startActivity(
                Intent(context, ImgActivity::class.java).putExtra(
                    "path",
                    item.fileVO?.netUrl.toString()
                ),  // 注意这里的sharedView
                // Content，View（动画作用view），String（和XML一样）
                ActivityOptions.makeSceneTransitionAnimation(
                    context as Activity,
                    it,
                    "sharedView"
                ).toBundle()
            )
        }
    }
}